using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;

using Peradigm.Framework.Domain.Security;
using Peradigm.Framework.Persistence;
using Peradigm.Framework.Persistence.Exceptions;

using Liberty.Domain.Kernel;

namespace Liberty.Persistence.Kernel
{
    public class StateBroker : ReferenceValueBroker<State>
    {
        #region Constants
        private const string SP_ALL_STATES = "AllStates";
        #endregion

        #region Event Handlers
        #endregion

        #region Methods
        /// <summary>
        /// Returns all states.
        /// </summary>
        /// <param name="serviceMember"></param>
        /// <returns></returns>
        public List<State> AllStates()
        {
            return this.Values();
        }

        /// <summary>
        /// Returns a State corresponding to the oid.
        /// </summary>
        /// <param name="oid"></param>
        /// <returns></returns>
        public State StateWith( long oid )
        {
            return this.ValueWith( oid );
        }

        /// <summary>
        /// Returns a State corresponding to the province.
        /// </summary>
        /// <param name="province"></param>
        /// <returns></returns>
        public State StateWith( string province )
        {
            return this.Values().Find( delegate( State state )
            {
                return state.Description.Equals( province );
            } );
        }
        #endregion

        #region Properties
        #endregion

        #region Private Methods
        #endregion

        #region Private Properties
        #endregion

        #region Construction and Finalization
        public StateBroker( string connectionString )
            : base( connectionString, SP_ALL_STATES )
        {
        }
        #endregion

        #region Data Elements
        #endregion
    }
}
